function compile() {
    printf "$2\t" >> run_result.txt
    for op in O0 O1 O2 O3 
    do
        echo gcc -DTHREAD_NUM=$2 $op $1.c -o $1
        gcc $1.c -$op -o $1
        echo ./$1
        ./$1 >> run_result.txt
        printf "\t" >> run_result.txt
    done
    

    # echo gcc -DTHREAD_NUM=$2 $1.c -O1 -o $1
    # gcc $1.c -O1 -o $1
    # echo ./$1
    # ./$1 >> run_result.txt
    # printf "\t" >> run_result.txt

    # echo gcc -DTHREAD_NUM=$2 $1.c -O2 -o $1
    # gcc $1.c -O2 -o $1
    # echo ./$1
    # ./$1 >> run_result.txt
    # printf "\t" >> run_result.txt

    # echo gcc -DTHREAD_NUM=$2 $1.c -O3 -o $1
    # gcc $1.c -O3 -o $1
    # echo ./$1
    # ./$1 >> run_result.txt
    echo ' ' >> run_result.txt
}

echo "run 3.1.3" > run_result.txt

printf "thd_n\tO0\tO1\tO2\tO3\n" > run_result.txt
for i in {1..12}
do
    compile 3.1.3 $i
done